package cn.ad.server.domain.enumration;

import java.util.HashMap;
import java.util.Map;

public enum Gender {
	
	UNKNOWN("Unknown",0),
    MALE("Male",1),  //男性
    FEMALE("Female",2);//女性

    private String name;
    private int value;
    
    private static java.util.HashMap<String,Integer> mappings;

    public static java.util.HashMap<String,Gender> genderMap;
    public static java.util.HashMap<Integer,Gender> genderMapByVal;

    static {
    	genderMap = new HashMap<>();
        for (Gender gender : values()) {
        	genderMap.put(gender.getName(), gender);
        }
    }

    static {
    	genderMapByVal = new HashMap<>();
    	for (Gender gender : values()) {
    		genderMapByVal.put(gender.getValue(), gender);
    	}
    }

    private synchronized static java.util.HashMap<String, Integer> getMappings() {
        if (mappings == null) {
            mappings = new java.util.LinkedHashMap<String, Integer>();
            for (Gender format : Gender.values()) {
                mappings.put(format.name, format.value);
            }
        }
        return mappings;
    }

    private Gender(String name, int value) {
        this.name = name;
        this.value = value;
    }

    public String getName() {
        return name;
    }

	public int getValue() {
		return value;
	}
	 public static Map<String,Integer> getMapping(){
	        return getMappings();
	 }
}
